1 00:00:00,510 --> 00:00:03,140 Hello and welcome to this lecture. 2 00:00:03,210 --> 00:00:09,270 In this lecture we will be creating some big game of our logic. 3 00:00:09,540 --> 00:00:18,900 The logic of the game will be that if we allow the ball to touch the bottom of the compass then the 4 00:00:18,900 --> 00:00:20,840 game is lost. 5 00:00:20,890 --> 00:00:26,670 That's the simple logic we are trying to implement in this lecture. 6 00:00:27,610 --> 00:00:34,370 At the moment the ball bounces off the fall was without nothin happening. 7 00:00:34,440 --> 00:00:41,940 What we going to do is make it bounce bounce off only the three walls bigger leaded bounce of the top 8 00:00:42,630 --> 00:00:44,530 left and the right. 9 00:00:44,850 --> 00:00:45,900 What we're going to do. 10 00:00:45,900 --> 00:00:54,810 We going to make him that if he touches the bottom of the Come that's then the game is lost so you've 11 00:00:54,810 --> 00:01:00,930 got to control the ball whether the paddle to make sure it does not touch the bottom of the compass 12 00:01:01,350 --> 00:01:03,240 anytime it touches the bottom. 13 00:01:03,480 --> 00:01:06,540 The game over are you get the popof Same. 14 00:01:06,540 --> 00:01:08,090 The game is over. 15 00:01:08,310 --> 00:01:11,730 That's what we're trying to implement here. 16 00:01:11,740 --> 00:01:17,110 All right this is the java script for the project. 17 00:01:17,490 --> 00:01:21,690 And inside the draw function here. 18 00:01:22,050 --> 00:01:26,250 This piece of code here the one highlighted here. 19 00:01:26,430 --> 00:01:36,900 This is what controls the Bunson of the ball off the four walls of the coverts we are going to amend 20 00:01:37,140 --> 00:01:42,810 this second statement here so that it does not. 21 00:01:42,840 --> 00:01:53,880 So if the ball touches the bottom of the covers we can implement alert that will show when the ball 22 00:01:53,880 --> 00:01:56,890 does the hand it will see Game over. 23 00:01:57,030 --> 00:02:06,800 So we will implement that here by amending this part of the if statement or right. 24 00:02:06,810 --> 00:02:13,030 I have already pre written the code here just to save a bit of time. 25 00:02:13,160 --> 00:02:16,690 So this is what I have done. 26 00:02:16,770 --> 00:02:21,970 This cause was from previous and I amended. 27 00:02:22,110 --> 00:02:29,840 Here we should a second block of code for Bunson the ball off the four walls of the canvas. 28 00:02:29,940 --> 00:02:42,360 So what I have done here on online 61 here have said if the variable y plus the variable D Y is less 29 00:02:42,360 --> 00:02:44,230 than the ball radius. 30 00:02:44,580 --> 00:02:52,650 I want the variable do you want to be equal to minus D y o k. 31 00:02:52,950 --> 00:03:02,370 If that's not the case then if the then I've got an ELSE IF statement which states that if the variable 32 00:03:02,370 --> 00:03:15,010 y blows a variable d y is greater than the height of the canvas minus the ball radius. 33 00:03:15,030 --> 00:03:21,660 If this condition is true thus And then I want I've also implemented. 34 00:03:21,860 --> 00:03:31,140 Be here is for when the ball touches the paddle at the moment there is no inter not in happens when 35 00:03:31,140 --> 00:03:32,340 they interact. 36 00:03:32,340 --> 00:03:40,340 So this here will create some kind of coalition detection between the ball and the paddle. 37 00:03:40,650 --> 00:03:49,370 So when the ball hits the paddle it will bounce off it and get back into the cumbersome plane area. 38 00:03:49,560 --> 00:03:53,890 That's what this bit of code here on line 65 is it. 39 00:03:53,910 --> 00:03:58,810 Ill look listen out for coalition detection between the ball and a paddle. 40 00:03:58,980 --> 00:04:02,760 So if the ball touches a puddle it will bounce back into the player era. 41 00:04:02,790 --> 00:04:08,170 That's what this bit is on online 64 sourcing. 42 00:04:08,420 --> 00:04:13,680 Yeah that's what this line 6 5 6 5 is. 43 00:04:13,680 --> 00:04:20,720 If so this is where the game logic will be implemented to determine to declare the game over. 44 00:04:21,300 --> 00:04:29,530 If the ball touches the bottom of the Come that's a tall alert. 45 00:04:29,760 --> 00:04:31,070 Game over. 46 00:04:31,240 --> 00:04:35,220 I need to reload the game to carry on again. 47 00:04:35,240 --> 00:04:43,070 All right so that's what the call is so the call the code this is a code that will be here 6 5 determines 48 00:04:43,070 --> 00:04:43,700 a coalition. 49 00:04:43,710 --> 00:04:48,470 When the ball hits the pad up to bounce off it. 50 00:04:48,510 --> 00:04:56,880 This court here from line 6 to 1 will all sorts the term in that if the ball touches the bottom of the 51 00:04:56,960 --> 00:04:59,750 comebacks this alert will. 52 00:05:00,220 --> 00:05:01,160 Displaced. 53 00:05:01,330 --> 00:05:04,460 So I'll say that and then we can see the court in that. 54 00:05:04,660 --> 00:05:05,220 Okay. 55 00:05:05,230 --> 00:05:08,510 That's the code in action at the moment. 56 00:05:08,560 --> 00:05:19,430 So if I try and control with my you can see bounces off the time it touches say bounces off the puddle 57 00:05:20,250 --> 00:05:24,160 that's me controlling it with my left or is hit the bottom. 58 00:05:24,160 --> 00:05:25,380 So game over. 59 00:05:25,570 --> 00:05:33,060 So I click okay here reloads the game and we play if will let me touch the bottom of the compass. 60 00:05:33,250 --> 00:05:38,660 It would be the game of US versus me control in the game or I missed that. 61 00:05:38,890 --> 00:05:46,000 So you can have a practice and control the game which your left some movement and the right curve some 62 00:05:46,000 --> 00:05:51,820 movement not allowing it to touch the bottom of the compass touches upon someone to come back. 63 00:05:52,060 --> 00:05:54,480 The game is over.